package org.zb.movement;

import org.newdawn.slick.geom.Vector2f;
import org.zb.controller.GameController;
import org.zb.controller.ObjectController;
import org.zb.object.MovingObject;

public class Movement {

	private ObjectController objectController = GameController.objectController;
	
	public boolean canMove(MovingObject object) {
		return canMove(object, object.size);
	}

	public boolean canMove(MovingObject object, float size) {
		object.calculatePositionAfterMovement();
		return !objectController.containsObjectsNear(object, size);
	}

	
	public Vector2f calculateAlternativeMovement(MovingObject object) {
		double delta = 5;
		//Vector2f storedMovement = new Vector2f(object.movement);
		for(int i = 0; i < 4 ; i++) {
			object.movement.add(delta);
			delta *= -2;
			if(canMove(object, object.size / 2))
				return object.movement;
		}
		return object.movement.scale(0);
	}
}
